package com.thundersoft.phonecontact;

import android.Manifest;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.support.v4.app.ActivityCompat;
import android.util.Log;


public class MyFunction {
    private static Intent callIntent;
    private static Intent shareIntent;
    private static final String TAG = "MyFunction";

    public static void makeCall(Context context, String number) {
        if (callIntent == null)
            callIntent = new Intent(Intent.ACTION_CALL);
        callIntent.setData(Uri.parse("tel:" + number));
        context.startActivity(callIntent);
    }

    public static Intent getShareIntent() {
        if (shareIntent == null)
            shareIntent = new Intent(Intent.ACTION_SEND);
        return shareIntent;
    }

    public static void makeMsg(Context context, String number) {
        Uri uri = Uri.parse("smsto:" + number);
        Intent msgIntent = new Intent(Intent.ACTION_SENDTO, uri);
//        msgIntent.setType("vnd.android-dir/mms-sms");
//        msgIntent.putExtra("address",number+"\n");
        Log.i(TAG, "makeMsg: " + number);
        context.startActivity(msgIntent);
    }

/*    public static void getPermission(Context context){
        ActivityCompat.requestPermissions(context,
                new String[]{Manifest.permission.READ_CALL_LOG,Manifest.permission.WRITE_CALL_LOG,
                Manifest.permission.CALL_PHONE,Manifest.permission.SEND_SMS},
                );
    }*/
}
